package com.itheima.createThread;

/**
 * 实现Runnable接口
 * 1. 编写类实现Runnable接口，重写run方法
 * 2. 将runnbale new出来的对象 交给thread类   Thread t = new Thread(runn);
 * 3. 创建对象，调用start()
 */
public class MyRunnable implements Runnable {

    @Override
    public void run() {
        for (int i = 0; i < 5; i++) {
            System.out.println(Thread.currentThread().getName() + ":"+i);
        }
    }
}

class Test2 {
    public static void main(String[] args) {
        Runnable myRunnable = new MyRunnable();
        Thread t = new Thread(myRunnable, "子线程1");
        t.start();
        for (int i = 0; i < 5; i++) {
            System.out.println(Thread.currentThread().getName()+":"+i);
        }
    }
}
